<template>
  <div class="app-container">
    <el-card class="filter-container" shadow="never">
      <div>
        <i class="el-icon-search"></i>
        <span>筛选搜索</span>
        <el-button
          style="float: right"
          @click="searchAdminDayStaticsList()"
          type="primary"
          size="small"
        >
          查询结果
        </el-button>
      </div>
      <div style="margin-top: 15px">
        <el-form
          :inline="true"
          :model="listQuery"
          size="small"
          label-width="140px"
        >
          <el-form-item label="输入搜索：">
            <el-input
              style="width: 203px"
              v-model="listQuery.kw"
              placeholder="请输入反馈内容"
            ></el-input>
          </el-form-item>
        </el-form>
      </div>
    </el-card>
    <div class="table-container">
      <el-table ref="schoolTable" :data="list" style="width: 100%" border>
        <!-- <el-table-column type="selection" width="60" align="center"></el-table-column> -->

        <el-table-column label="编号" align="center">
          <template slot-scope="scope">{{ scope.row.id }}</template>
        </el-table-column>
        <el-table-column label="用户ID" align="center">
          <template slot-scope="scope">{{ scope.row.userId }}</template>
        </el-table-column>
        <el-table-column label="用户昵称" align="center">
          <template slot-scope="scope">{{ scope.row.nickName }}</template>
        </el-table-column>
        <el-table-column label="用户电话" align="center">
          <template slot-scope="scope">{{ scope.row.phone }}</template>
        </el-table-column>
        <el-table-column label="反馈内容" align="center">
          <template slot-scope="scope">{{ scope.row.content }}</template>
        </el-table-column>
        <!-- <el-table-column label="图片" align="center">
          <template slot-scope="scope">
              <img :src="scope.row.img" style="width:100px;height:100px;"/>
          </template>
        </el-table-column> -->
        <el-table-column label="图片" align="center">
          <template slot-scope="scope">
            <!-- <el-image
              :src="scope.row.pics[0]"
              lazy
              :preview-src-list="scope.row.pics"
            ></el-image> -->
            <el-popover
              placement="right"
              width="400"
              trigger="click"
              v-if="scope.row.img"
            >
              <div
                class="demo-image__lazy"
                style="max-height: 600px; overflow-y: scroll; background: #fff"
              >
                <el-image
                  v-for="url in scope.row.img.split(',')"
                  :key="url"
                  :src="url"
                  style="width: 100%; margin-bottom: 6px"
                ></el-image>
              </div>
              <el-button slot="reference">查看</el-button>
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column label="创建时间" align="center">
          <template slot-scope="scope">{{
            scope.row.creatTime | formatTime
          }}</template>
        </el-table-column>

        <!-- <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button size="mini" @click="handleUpdate(scope.$index, scope.row)">编辑</el-button>
            <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
          </template>
        </el-table-column> -->
      </el-table>
    </div>
    <div class="pagination-container">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        layout="total, sizes,prev, pager, next,jumper"
        :page-size="listQuery.pageSiz"
        :page-sizes="[10, 15, 50]"
        :current-page.sync="listQuery.pageNum"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { fetchList } from "@/api/ums/opinion";
import { formatDate } from "@/utils/date";
export default {
  data() {
    return {
      listQuery: {
        kw: "",
        pageSiz: 10,
        pageNum: 1,
      },
      list: [],
      total: null,
      listLoading: true,
    };
  },
  filters: {
    formatTime(time) {
      if (time == null || time === "") {
        return "N/A";
      }
      let date = new Date(time);
      return formatDate(date, "yyyy-MM-dd hh:mm:ss");
    },
  },
  methods: {
    handleCurrentChange(val) {
        this.listQuery.pageNum = val;
        this.getList();
      },
    handleSizeChange(val) {
        this.listQuery.pageNum = 1;
        this.listQuery.pageSiz = val;
        this.getList();
      },
    getList() {
      this.listLoading = true;
      fetchList(this.listQuery).then((response) => {
        this.listLoading = false;
        this.list = response.data.records;
        this.total = response.data.total;
        this.totalPage = response.data.pages;
        this.pageSize = response.data.size;
      });
    },
    searchAdminDayStaticsList() {
      this.listQuery.pageNum = 1;
      this.getList();
    },
  },
  created() {
    this.getList();
  },
};
</script>

<style lang="scss" scoped>
</style>